Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
38 lines (31 loc) · 852 Bytes

3.9.6 - Coroutine/PostgreSQL->fetchObject.md

File metadata and controls

38 lines (31 loc) · 852 Bytes

Coroutine\PostgreSQL->fetchObject

提取一行作为对象

function Coroutine\PostgreSQL->fetchObject(resource $queryResult [, int $row);

example:

go(function () {

    $a = new Swoole\Coroutine\PostgreSQL();
    $conn  = $a -> connect ("host=127.0.0.1 port=5432 dbname=test user=wuzhenyu");
    $result = $a->query('SELECT * FROM test;');

	$row = 0;
	while ($data = $a->fetchObject($result, $row)) {
    	echo $data->id . " \n ";
    	$row++;
	}
	
});

或者

go(function () {
    $a = new Swoole\Coroutine\PostgreSQL();
    $conn  = $a -> connect ("host=127.0.0.1 port=5432 dbname=test user=wuzhenyu");
    $result = $a->query('SELECT * FROM test;');

    $row = 0;
    for ($row = 0 ;$row < $a->numRows($result);$row++){
        $data = $a->fetchObject($result, $row);
        echo $data->id . " \n ";
    }
});